import { computed, ref } from 'vue'
import { Good } from '../components/types'
import _ from 'lodash'

const _selectedGoodList = ref<Good[]>([])

export default () => {
  const selectedGoodList = computed(() => _.cloneDeep(_selectedGoodList.value))

  const addSelectedGood = (data: Good) => {
    _selectedGoodList.value.push(data)
  }

  const setSelectedGoodList = (data: Array<Good>) => {
    _selectedGoodList.value = data
  }

  return {
    selectedGoodList,
    addSelectedGood,
    setSelectedGoodList,
  }
}
